package edu.princeton.cogsci.wn;

/**
 *  This class models a lexical entry, or one sense of a word.
 *
 */

public class WordSense
{

  /* Instance variables */


  /** The orthographic form, or spelling. */
  private String form;
  
  /** The part of speech. @see Constants */
  private int pos;
  
  /** The sense number. */
  private int sense;
  
  /** The polysemy count, or primary familiarity index. */
  private int polysemy;
  
  /** The frequency count, or secondary familiarity index. */
  private int frequency;
  
  /** The synset that contains this word sense. */
  private Synset synset;
  
  /** The set of lexical relations. */
  private LexicalRelation[] relations;
  
  /** The key that uniquely identifies this word sense. */
  private WordSenseKey key;
  
  /** The set of verb frames that apply only to this word (and not its
   *  synonyms).
   *
   *  @see Constants
   */
  private int[] frames;


  /* Accessor methods */


  /** Returns the orthographic form, or spelling. */
  public String getForm( ) { return form; }
  
  /** Returns the part of speech. @see Constants */
  public int getPos( ) { return getSynset( ).getPos( ); }
  
  /** Returns the sense number. */
  public int getSense( ) { return sense; }
  
  /** Returns the polysemy count, or primary familiarity index. */
  public int getPolysemy( ) { return polysemy; }
  
  /** Returns the frequency count, or secondary familiarity index. */
  public int getFrequency( ) { return frequency; }
  
  /** Returns the synset that contains this word sense. */
  public Synset getSynset( ) { return synset; }
  
  /** Returns the set of lexical relations. */
  public LexicalRelation[] getRelations( ) { return relations; }
  
  /** Returns the key that uniquely identifies this word sense. */
  public WordSenseKey getKey( ) { return key; }


  /* Mutator methods */


  /** Sets the orthographic form, or spelling. */
  public void setForm( String form ) { this.form = form; }
  
  /** Sets the part of speech. @see Constants */
  public void setPos( int pos ) { this.pos = pos; }
  
  /** Sets the sense number. */
  public void setSense( int sense ) { this.sense = sense; }
  
  /** Sets the polysemy count, or primary familiarity index. */
  public void setPolysemy( int polysemy ) { this.polysemy = polysemy; }
  
  /** Sets the frequency count, or secondary familiarity index. */
  public void setFrequency( int frequency ) { this.frequency = frequency; }
  
  /** Sets the synset that contains this word sense. */
  public void setSynset( Synset synset ) { this.synset = synset; }
  
  /** Sets the set of lexical relations. */
  public void setRelations( LexicalRelation[] r ) { this.relations = r; }
  
  /** Sets the key that uniquely identifies this word sense. */
  public void setKey( WordSenseKey key ) { this.key = key; }
  
  
  /* Utility methods */


  /** Returns the string representation of this word sense, namely, the
   *  orthographic form with spaces replacing underscores.
   */
  public String toString( )
  {
    return getForm( ).replace( '_', ' ' );
  }

  /** Returns the full string representation of this word sense, namely, the
   *  orthographic form with spaces replacing underscores concatenated with
   *  a character representing the part of speech and the sense number.
   */
  public String toStringFull( )
  {
    return toString( ) +
           "(" + Constants.posChars[ getPos( ) ] + ":" + sense + ")";
  }

  /** Compares this word sense to another object. If the other object is a
   *  string, compares the string representation of this object to it;
   *  otherwise, compares the objects as <CODE>Object</CODE>s.
   */
  public boolean equals( Object other )
  {
    if ( other instanceof String )
      return toString( ).equals( other );
    else
      return super.equals( other );
  }
}
